package com.yh.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yh.common.BaseResult;
import com.yh.entity.SysUserRole;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import com.yh.service.ISysUserRoleService;
import org.springframework.web.bind.annotation.RestController;
import lombok.AllArgsConstructor;

/**
 * <p>
 * 用户和角色关联表 前端控制器
 * </p>
 *
 * @author yh
 * @since 2021-05-10
 */
@AllArgsConstructor
@RestController
@RequestMapping("/sys-user-role")
public class SysUserRoleController {
    private final ISysUserRoleService sysUserRoleService;

    @GetMapping("/getPage")
    public BaseResult getPageSysUserRole(Integer pageNum,Integer pageSize){
        Page<SysUserRole> page = sysUserRoleService.getPageSysUserRole(pageNum, pageSize);
        return BaseResult.success(page);
    }

    @PostMapping("/save")
    public BaseResult save(SysUserRole sysUserRole){
        sysUserRole = sysUserRoleService.saveSysUserRole(sysUserRole);
        return BaseResult.success(sysUserRole);
    }

    @PutMapping("/update")
    public BaseResult update(SysUserRole sysUserRole){
        sysUserRole = sysUserRoleService.updateSysUserRole(sysUserRole);
        return BaseResult.success(sysUserRole);
    }

    @GetMapping("/getInfo")
    public BaseResult getInfo(String id){
        SysUserRole sysUserRole = sysUserRoleService.getInfo(id);
        return BaseResult.success(sysUserRole);
    }
}

